package com.czk.localdatetime;

import java.sql.Time;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.concurrent.TimeUnit;

/**
 * @Author:ChenZhangKun
 * @Date: 2023/1/28 21:20
 */
public class NewYear {
    public static void main(String[] args) throws InterruptedException {

        while (true) {
            TimeUnit.SECONDS.sleep(1);

            LocalDateTime now = LocalDateTime.now();

            LocalDateTime newYear = LocalDateTime.of(2024, 2, 10, 0, 0, 0);

            long year = now.until(newYear, ChronoUnit.YEARS);

            now= now.plusYears(year);

            long month = now.until(newYear, ChronoUnit.MONTHS);
            now=now.plusMonths(month);
            long day = now.until(newYear, ChronoUnit.DAYS);
            now=now.plusDays(day);
            long hour = now.until(newYear, ChronoUnit.HOURS);
            now=now.plusHours(hour);
            long minute = now.until(newYear, ChronoUnit.MINUTES);
            now=now.plusMinutes(minute);
            long SECONDS = now.until(newYear, ChronoUnit.SECONDS);

            System.out.print("\r"+year + "年" + month + "月" + day + "天" + hour + "时" + minute + "分" + SECONDS + "秒");
        }



    }
}
